#include "logindialog.h"
#include "ui_logindialog.h"

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    ui->setupUi(this);
    m = new MainWindow(0);
    connect(this,SIGNAL(add_user(QString,quint16,QString)),m,SLOT(add_user(QString,quint16,QString)));
    ui->host->setText("127.0.0.1");
    ui->port->setText("37888");
    //ui->name->setText("adam");
}

LoginDialog::~LoginDialog()
{

    delete ui;

}

void LoginDialog::on_buttonBox_accepted()
{
    QString name = ui->name->text();
    quint16 port = ui->port->text().toUShort();
    QString host = ui->host->text();

    if(name=="all"){
        if(QMessageBox::critical(this, tr("Error"),tr("For some reason, do not use \"all\" as name:)"))){
                    return ;
        }
    }


    emit add_user(host,port,name);

}

